package com.lf.web.service.system.group;

import com.lf.data.Global;
import com.lf.data.Page;
import com.lf.data.search.Field;
import com.lf.data.search.Query;
import com.lf.web.service.ServiceSupport;

import java.util.List;
import java.util.Map;

public class GroupListService extends ServiceSupport {

    private GroupDAO groupdao;
    private Map<String, Object> groups = null;
    private Page page = new Page();

    public GroupListService() {
    }

    public void setGroupdao(GroupDAO groupdao) {
        this.groupdao = groupdao;
    }

    private void initParamValue() {
        form.getBean(page);
    }

    public String execute() {
        initParamValue();
        Group group = new Group();
        Field field = new Field();
        Query query = new Query();
        field.include(group.NAME, group.CREATED);
        groups = groupdao.findPage(null, field, null, page);
        List<Map<String, Object>> list = (List<Map<String, Object>>) groups.get(Global.PAGE_LIST);
        putData();
        return LIST;
    }

    private void putData() {
        context.put("groups", groups);
    }
}
